{"ast":null,"code":"var _jsxFileName = \"/data/messenger.client/src/containers/Contacts.tsx\",\n  _s = $RefreshSig$();\nimport React from \"react\";\nimport { ContactsBlock } from \"../components/\";\nimport { Context } from \"../index\";\nimport { observer } from \"mobx-react-lite\";\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nconst Contacts = () => {\n  _s();\n  const {\n    store\n  } = React.useContext(Context);\n  const [contacts, setContacts] = React.useState({\n    ...(store.getContacts() || {\n      items: []\n    })\n  });\n  const [flag, setFlag] = React.useState(false);\n  const [addRequests, setAddRequests] = React.useState(),\n    [sentRequests, setSentRequests] = React.useState(),\n    [allRequests, setAllRequests] = React.useState();\n  React.useEffect(() => {\n    if (!flag && store.getChats().items === undefined) {\n      store.getChatsFromAPI().then();\n    } else {\n      setFlag(true);\n    }\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, []);\n  React.useEffect(() => {\n    if (store.getContacts()) {\n      setContacts({\n        ...contacts,\n        ...store.getContacts()\n      });\n    }\n    let tempAddRequests = {\n        items: []\n      },\n      tempSentRequests = {\n        items: []\n      },\n      tempAllRequests = {\n        items: []\n      };\n    if (contacts.items) {\n      contacts.items.map((item, index) => {\n        if (item.toUser.id === store.getProfile().id && !item.status) {\n          tempAddRequests.items[index] = item;\n        } else if (item.fromUser.id === store.getProfile().id && !item.status) {\n          tempSentRequests.items[index] = item;\n        } else {\n          tempAllRequests.items[index] = item;\n        }\n      });\n    }\n    setAddRequests({\n      ...addRequests,\n      ...tempAddRequests\n    });\n    setSentRequests({\n      ...sentRequests,\n      ...tempSentRequests\n    });\n    setAllRequests({\n      ...allRequests,\n      ...tempAllRequests\n    });\n    // eslint-disable-next-line react-hooks/exhaustive-deps\n  }, [store.contacts]);\n  return /*#__PURE__*/_jsxDEV(ContactsBlock, {\n    currentUser: store.getProfile(),\n    addRequestList: addRequests || {\n      items: []\n    },\n    sentRequestList: sentRequests || {\n      items: []\n    },\n    allAcceptedList: allRequests || {\n      items: []\n    }\n  }, void 0, false, {\n    fileName: _jsxFileName,\n    lineNumber: 69,\n    columnNumber: 9\n  }, this);\n};\n_s(Contacts, \"JPwNyMinbraxz9ldFURyTzlUUEU=\");\n_c = Contacts;\nexport default _c2 = observer(Contacts);\nvar _c, _c2;\n$RefreshReg$(_c, \"Contacts\");\n$RefreshReg$(_c2, \"%default%\");","map":{"version":3,"names":["React","ContactsBlock","Context","observer","Contacts","store","useContext","contacts","setContacts","useState","getContacts","items","flag","setFlag","addRequests","setAddRequests","sentRequests","setSentRequests","allRequests","setAllRequests","useEffect","getChats","undefined","getChatsFromAPI","then","tempAddRequests","tempSentRequests","tempAllRequests","map","item","index","toUser","id","getProfile","status","fromUser"],"sources":["/data/messenger.client/src/containers/Contacts.tsx"],"sourcesContent":["import React from \"react\";\nimport {ContactsBlock} from \"../components/\";\nimport {Context} from \"../index\";\nimport {observer} from \"mobx-react-lite\";\nimport {ContactListResponse} from \"../models/response/ContactListResponse\";\n\nconst Contacts:React.FC = () => {\n    const {store} = React.useContext(Context);\n    const [contacts, setContacts] = React.useState<ContactListResponse>({...store.getContacts() || {items: []}});\n    const [flag, setFlag] = React.useState<boolean>(false);\n\n    const [addRequests, setAddRequests] = React.useState<ContactListResponse>(),\n          [sentRequests, setSentRequests] = React.useState<ContactListResponse>(),\n          [allRequests, setAllRequests] = React.useState<ContactListResponse>();\n\n    React.useEffect(() => {\n        if (!flag && store.getChats().items === undefined) {\n            store.getChatsFromAPI().then();\n        } else {\n            setFlag(true);\n        }\n        // eslint-disable-next-line react-hooks/exhaustive-deps\n    }, []);\n\n    React.useEffect(() => {\n\n        if (store.getContacts()) {\n            setContacts({\n                ...contacts,\n                ...store.getContacts()\n            });\n        }\n\n        let tempAddRequests = {items: []} as ContactListResponse,\n            tempSentRequests = {items: []} as ContactListResponse,\n            tempAllRequests = {items: []} as ContactListResponse;\n\n        if (contacts.items) {\n            contacts.items.map((item, index) => {\n                if (item.toUser.id === store.getProfile().id && !item.status) {\n                    tempAddRequests.items[index] = item;\n                } else if (item.fromUser.id === store.getProfile().id && !item.status) {\n                    tempSentRequests.items[index] = item;\n                } else {\n                    tempAllRequests.items[index] = item;\n                }\n            });\n        }\n\n        setAddRequests({\n            ...addRequests,\n            ...tempAddRequests\n        });\n\n        setSentRequests({\n            ...sentRequests,\n            ...tempSentRequests\n        });\n\n        setAllRequests({\n            ...allRequests,\n            ...tempAllRequests\n        });\n        // eslint-disable-next-line react-hooks/exhaustive-deps\n    }, [store.contacts]);\n\n\n    return (\n        <ContactsBlock\n            currentUser={store.getProfile()}\n            addRequestList={addRequests || {items: []}}\n            sentRequestList={sentRequests || {items: []}}\n            allAcceptedList={allRequests || {items: []}}\n        />\n    );\n\n};\n\nexport default observer(Contacts);"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAQC,aAAa,QAAO,gBAAgB;AAC5C,SAAQC,OAAO,QAAO,UAAU;AAChC,SAAQC,QAAQ,QAAO,iBAAiB;AAAC;AAGzC,MAAMC,QAAiB,GAAG,MAAM;EAAA;EAC5B,MAAM;IAACC;EAAK,CAAC,GAAGL,KAAK,CAACM,UAAU,CAACJ,OAAO,CAAC;EACzC,MAAM,CAACK,QAAQ,EAAEC,WAAW,CAAC,GAAGR,KAAK,CAACS,QAAQ,CAAsB;IAAC,IAAGJ,KAAK,CAACK,WAAW,EAAE,IAAI;MAACC,KAAK,EAAE;IAAE,CAAC;EAAA,CAAC,CAAC;EAC5G,MAAM,CAACC,IAAI,EAAEC,OAAO,CAAC,GAAGb,KAAK,CAACS,QAAQ,CAAU,KAAK,CAAC;EAEtD,MAAM,CAACK,WAAW,EAAEC,cAAc,CAAC,GAAGf,KAAK,CAACS,QAAQ,EAAuB;IACrE,CAACO,YAAY,EAAEC,eAAe,CAAC,GAAGjB,KAAK,CAACS,QAAQ,EAAuB;IACvE,CAACS,WAAW,EAAEC,cAAc,CAAC,GAAGnB,KAAK,CAACS,QAAQ,EAAuB;EAE3ET,KAAK,CAACoB,SAAS,CAAC,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